home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
UNIX
/
C
/
C-STYLE
/
STYLE_ME.AWK
< prev
next >
Wrap
Text File
|
1992-11-23
|
876b
|
35 lines
# Produce "style" metrics for a C program
# Compute number of blank lines
{ if (NF==0) { blank++; next }}
# Compute number of nunblank characters and embedded spaces
{ nbchars = 0
for ( i = NF; i > 0; i-- ) nbchars += length($i)
nonblank += nbchars
start = index ($0, $1)
embedded += length - nbchars - ( start - 1) }
# Compute amount of indentation
/^[ ]/ { indented += index($0,$1) -1 }
# Compute total number of characters
{ chars += length }
# Compute number of modules
/^[a-z_][a-z_0-9]*[ a-z_0-9]*\(.*\)/ { module++ }
# Compute number of goto's
/^goto[ ]+|[ ]+goto[ ]+/ { jumps++ }
# Report results
END { print "NR " (NR+0)
print "LC " (NR-blank)
print "NB " (nonblank+0)
print "IN " (indented+0)
print "TC " (chars+0)
print "BL " (blank+0)
print "IM " (embedded+0)
print "MO " (module+0)
print "JU " (jumps+0) }